<template>
  <div>
    <el-tabs v-model="activeKey" @tab-click="tabClick">
      <el-tab-pane label="财务汇总" name="1"></el-tab-pane>
      <!-- <el-tab-pane label="业务订单" name="2"></el-tab-pane> -->
      <el-tab-pane label="支付订单" name="3"></el-tab-pane>
      <el-tab-pane label="退款查询" name="4"></el-tab-pane>
      <el-tab-pane label="微信红包" name="5"></el-tab-pane>
      <el-tab-pane label="企业付款" name="6"></el-tab-pane>
      <!-- <el-tab-pane label="企业批量付款" name="7"></el-tab-pane> -->
    </el-tabs>

    <el-card style="min-width: 1200px">
      <div v-if="eventTab == '1'" class="tableSelectWrap">
        <el-form ref="dealSearchForm" :model="commandForm" label-width="100px">
          <el-row>
            <el-col :span="7" v-if="activeKey == '1'">
              <el-form-item label="选择时间" prop="date">
                <el-date-picker
                  style="width: 100%"
                  v-model="commandForm.date"
                  type="month"
                  value-format="yyyy-MM"
                  placeholder="选择日期"
                  :picker-options="pickerOptions"
                  :clearable="false"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col
              :span="7"
              v-if="activeKey == '2' || activeKey == '3'"
              style="display: flex"
            >
              <el-form-item label-width="0" prop="dateType">
                <el-select
                  v-model="commandForm.dateType"
                  placeholder="选择时间"
                  class="leftSelect"
                  style="width: 100px; border-radius: 0px"
                >
                  <el-option label="创建时间" value="create"></el-option>
                  <el-option label="支付时间" value="pay"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label-width="0" prop="date2" style="flex: 1">
                <el-date-picker
                  :clearable="false"
                  v-model="commandForm.date2"
                  style="width: 100%; border-radius: 0px; margin-top: 1px"
                  class="rightSelect"
                  type="datetimerange"
                  :default-time="['00:00:00', '23:59:59']"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  start-placeholder="开始时间"
                  end-placeholder="结束时间"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="7" v-if="activeKey == '4'" style="display: flex">
              <el-form-item label-width="0" prop="dateType2">
                <el-select
                  v-model="commandForm.dateType2"
                  placeholder="选择时间"
                  class="leftSelect"
                  style="width: 100px; border-radius: 0px"
                  :unlink-panels="true"
                >
                  <el-option label="创建时间" value="create"></el-option>
                  <!-- <el-option label="退款时间" value="refund"></el-option> -->
                </el-select>
              </el-form-item>
              <el-form-item label-width="0" prop="date3" style="flex: 1">
                <el-date-picker
                  :clearable="false"
                  v-model="commandForm.date3"
                  style="width: 100%; border-radius: 0px; margin-top: 1px"
                  class="rightSelect"
                  type="datetimerange"
                  :default-time="['00:00:00', '23:59:59']"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  start-placeholder="开始时间"
                  end-placeholder="结束时间"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="7" v-if="activeKey == '5' || activeKey == '6'">
              <el-form-item label="选择时间" prop="date4" style="flex: 1">
                <el-date-picker
                  :clearable="false"
                  v-model="commandForm.date4"
                  style="width: 100%; border-radius: 0px; margin-top: 1px"
                  class="rightSelect"
                  type="datetimerange"
                  :default-time="['00:00:00', '23:59:59']"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  start-placeholder="开始时间"
                  end-placeholder="结束时间"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="7" v-if="activeKey == '7'">
              <el-form-item label="选择时间" prop="date5" style="flex: 1">
                <el-date-picker
                  :clearable="false"
                  v-model="commandForm.date5"
                  style="width: 100%; border-radius: 0px; margin-top: 1px"
                  class="rightSelect"
                  type="datetimerange"
                  :default-time="['00:00:00', '23:59:59']"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  start-placeholder="开始时间"
                  end-placeholder="结束时间"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>

            <el-col :span="7" :offset="1" v-if="activeKey == '1'">
              <el-form-item label="交易类型" prop="transactioType">
                <el-select
                  v-model="commandForm.transactioType"
                  class="leftSelect"
                  style="width: 100%"
                  placeholder="请选择交易类型"
                >
                  <el-option
                    v-for="item of transactiotypeList"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col v-if="activeKey == '2'" :span="7" :offset="1">
              <el-form-item label="订单状态" prop="payStatus">
                <el-select
                  v-model="commandForm.payStatus"
                  style="width: 100%"
                  placeholder="请选择订单状态"
                  clearable
                >
                  <el-option
                    v-for="item of orderStateList"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col v-if="activeKey == '4'" :span="7" :offset="1">
              <el-form-item label="退款状态" prop="refundStatus">
                <el-select
                  clearable
                  v-model="commandForm.refundStatus"
                  style="width: 100%"
                  placeholder="请选择退款状态"
                >
                  <el-option
                    v-for="item of activeKey == '4'
                      ? refundStateList
                      : refundStateList1"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col v-if="activeKey == '6'" :span="7" :offset="1">
              <el-form-item label="付款状态" prop="status">
                <el-select
                  v-model="commandForm.status"
                  style="width: 100%"
                  placeholder="请选择付款状态"
                  clearable
                >
                  <el-option
                    v-for="item of payStateList1"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col
              :span="7"
              :offset="1"
              :style="{
                display:
                  activeKey != '1' &&
                  activeKey != '6' &&
                  activeKey != '7' &&
                  commandForm.payformChannel
                    ? 'flex'
                    : '',
              }"
            >
              <el-form-item
                label="支付渠道"
                v-if="activeKey !== '2'"
                prop="payformChannel"
              >
                <el-select
                  clearable
                  v-model="commandForm.payformChannel"
                  class="leftSelect"
                  style="width: 100%"
                  placeholder="请选择支付渠道"
                  @change="handleChannel"
                >
                  <el-option
                    v-for="(item, index) of payChannel"
                    :key="index"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
              <el-form-item
                label=""
                prop="payType"
                label-width="0"
                v-if="
                  activeKey != '1' &&
                  activeKey != '6' &&
                  activeKey != '7' &&
                  commandForm.payformChannel
                "
              >
                <el-select
                  clearable
                  class="rightSelect"
                  v-model="commandForm.payType"
                  style="width: 100%"
                  placeholder="请选择"
                >
                  <el-option
                    v-for="(item, index) of payChannelTypeList"
                    :key="index"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col v-if="activeKey == '5'" :span="7" :offset="1">
              <el-form-item label="红包状态" prop="status">
                <el-select
                  clearable
                  v-model="commandForm.status"
                  style="width: 100%"
                  placeholder="请选择红包状态"
                >
                  <el-option
                    v-for="item of redPackList"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col v-if="activeKey == '3'" :span="7" :offset="1">
              <el-form-item label="退款状态" prop="refundState">
                <el-select
                  clearable
                  v-model="commandForm.refundState"
                  style="width: 100%"
                  placeholder="请选择退款状态"
                >
                  <el-option
                    v-for="item of refundCaseList"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <!-- <el-col v-if="activeKey == '5'" :span="7" :offset="1">
              <el-form-item :label="activeKey == '1' ? '收款方' : '退款方'">
                <el-select
                  v-model="commandForm.memberId"
                  style="width: 100%"
                  filterable
                  remote
                  clearable
                  :placeholder="`请输入${
                    activeKey == '1' ? '收款方' : '退款方'
                  }名称或ID`"
                  :remote-method="remoteMethod"
                  @change="changeValue($event)"
                  @focus="setId1()"
                >
                  <el-option
                    v-for="item of merchantList"
                    :key="item.id"
                    :label="item.memberName"
                    :value="item.id"
                  >
                    <div
                      style="
                        color: #999999;
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                        width: 350px;
                      "
                    >
                      {{ item.memberName }} 商户ID :{{ item.memberNo }}
                    </div>
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col> -->
            <el-col
              v-if="
                activeKey !== '1' &&
                activeKey !== '3' &&
                activeKey !== '4' &&
                activeKey !== '5' &&
                activeKey !== '6'
              "
              :span="7"
              :offset="1"
              style="min-width: 170px"
            >
              <el-button class="width120" @click="this.tabClick1"
                >重置</el-button
              >
              <el-button
                type="primary"
                class="width120"
                @click="
                  () => {
                    this.dataForm = JSON.parse(
                      JSON.stringify(this.commandForm)
                    );
                    this.handleQuery();
                  }
                "
                >查询</el-button
              >
            </el-col>
          </el-row>
          <el-row>
            <el-col v-if="activeKey == '3'" :span="7">
              <el-form-item label="支付状态" prop="status">
                <el-select
                  v-model="commandForm.status"
                  style="width: 100%"
                  placeholder="请选择支付状态"
                  clearable
                >
                  <el-option
                    v-for="item of payStateList"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col
              v-if="
                activeKey == '1' ||
                activeKey == '3' ||
                activeKey == '4' ||
                activeKey == '5' ||
                activeKey == '6'
              "
              :span="7"
              :offset="activeKey == '3' ? '1' : '0'"
            >
              <el-form-item label="所属商户" prop="transactioType">
                <el-select
                  v-model="commandForm.memberId"
                  class="leftSelect"
                  style="width: 100%"
                  placeholder="请选择商户"
                >
                  <el-option
                    v-for="item of merchaList"
                    :key="item.id"
                    :label="item.memberName"
                    :value="item.id"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <!-- <el-col v-if="activeKey == '2'" :span="7">
              <el-form-item
                label="分账模式"
                prop="settleMode"
                style="margin-bottom: -10px"
              >
                <el-select
                  clearable
                  v-model="commandForm.settleMode"
                  style="width: 100%"
                  placeholder="请选择分账模式"
                >
                  <el-option
                    v-for="item of settleModeList"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col> -->
            <!-- <el-col v-if="activeKey == '4'" :span="7">
              <el-form-item
                :label="
                  activeKey == '6'
                    ? '付款方'
                    : activeKey == '4'
                    ? '退款方'
                    : '收款方'
                "
                prop="memberId"
              >
                <el-select
                  v-model="commandForm.memberId"
                  style="width: 100%"
                  filterable
                  remote
                  clearable
                  :placeholder="`请输入${
                    activeKey == '6'
                      ? '付款'
                      : activeKey == '4'
                      ? '退款'
                      : '收款'
                  }方名称或ID`"
                  :remote-method="remoteMethod"
                  @change="changeValue($event)"
                  @focus="setId1()"
                >
                  <el-option
                    v-for="item of merchantList"
                    :key="item.id"
                    :label="item.memberName"
                    :value="item.id"
                    class="height70"
                  >
                    <div
                      style="
                        color: #999999;
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                        width: 350px;
                      "
                    >
                      {{ item.memberName }} 商户ID :{{ item.memberNo }}
                    </div>
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col> -->
            <el-col
              v-if="
                activeKey == '1' ||
                activeKey == '3' ||
                activeKey == '4' ||
                activeKey == '5' ||
                activeKey == '6'
              "
              :span="7"
              :offset="
                activeKey == '1' ||
                activeKey == '3' ||
                activeKey == '4' ||
                activeKey == '5' ||
                activeKey == '6'
                  ? 1
                  : 0
              "
              style="min-width: 170px"
            >
              <el-button class="width120" @click="this.tabClick1"
                >重置</el-button
              >
              <el-button
                type="primary"
                class="width120"
                @click="
                  () => {
                    this.dataForm = JSON.parse(
                      JSON.stringify(this.commandForm)
                    );
                    this.handleQuery();
                  }
                "
                >查询</el-button
              >
            </el-col>
          </el-row>
          <el-row
            v-if="activeKey == '2' || activeKey == '3' || activeKey == '4'"
          >
            <el-button
              @click="exchangeEventTab"
              icon="el-icon-search"
              class="searchBtn"
              >精确搜索</el-button
            >
          </el-row>
        </el-form>
      </div>
      <div v-if="eventTab == '2'" class="tabWrap">
        <el-input
          v-if="activeKey == '3' || activeKey == '4' || activeKey == '5'"
          class="search"
          clearable
          :placeholder="
            activeKey == '4'
              ? '请输入退款订单号/退款流水号'
              : activeKey == '5'
              ? '请输入批量退款批次号'
              : '请输入商户订单号/商品名称/渠道流水号/云尘付流水号'
          "
          @keyup.enter.native="globalQuery"
          v-model="commandForm.searchVal"
        >
          <!-- <i slot="prefix" class="el-input__icon el-icon-search-outlined"></i> -->
        </el-input>
        <div class="searBtn">
          <el-button
            type="primary"
            @click="
              () => {
                this.dataForm = JSON.parse(JSON.stringify(this.commandForm));
                this.globalQuery();
              }
            "
            >搜索</el-button
          >
        </div>
        <div class="backWrap" @click="exchangeEventTab">
          <span>筛选搜索</span>
          <img src="@/assets/imgs/setting/down1.png" />
        </div>
      </div>
    </el-card>
    <el-card
      class="textBox"
      style="min-width: 1200px; margin-bottom: -5px; margin-top: 15px"
      v-if="activeKey != '4' && activeKey != '5'"
    >
      <span class="numBox" v-if="activeKey != '3' && activeKey != '4'">
        <span>{{
          activeKey == "1"
            ? "月收入总额"
            : activeKey == "2"
            ? "订单总额"
            : activeKey == "5"
            ? "退款总额"
            : activeKey == "6"
            ? "企业付款总额"
            : "企业批量付款总额"
        }}</span>
        <span class="symbol">￥</span>
        <span class="num" v-if="activeKey == '1'">{{
          financialStatisticsInfo.fmtIncomeTotalAmount || "0.00"
        }}</span>
        <span class="num" v-if="activeKey == '2'">{{
          orderStatisticsInfo1
            ? orderStatisticsInfo1.fmtOrderTotalAmount
            : "0.00"
        }}</span>
        <span class="num" v-if="activeKey == '4' || activeKey == '5'">{{
          refundStatisticsInfo
            ? refundStatisticsInfo.fmtRefundTotalAmount
            : "0.00"
        }}</span>
        <span class="num" v-if="activeKey == '6' || activeKey == '7'">{{
          enterpriseStatisticsInfo
            ? enterpriseStatisticsInfo.fmtTransferPayTotalAmount
            : "0.00"
        }}</span>
      </span>
      <span class="numBox" v-if="activeKey != '4'">
        <span>{{
          activeKey == "1"
            ? "月支出总额"
            : activeKey == "2"
            ? "支付总额"
            : activeKey == "3"
            ? "总金额"
            : activeKey == "5"
            ? "退款量"
            : "付款总量"
        }}</span>
        <span
          class="symbol"
          v-if="activeKey == '1' || activeKey == '2' || activeKey == '3'"
          >￥</span
        >
        <span class="num" v-if="activeKey == '1'">{{
          financialStatisticsInfo.fmtPayoutTotalAmount || "0.00"
        }}</span>
        <span class="num" v-if="activeKey == '2'">{{
          orderStatisticsInfo1 ? orderStatisticsInfo1.fmtPayTotalAmount : "0.00"
        }}</span>
        <span class="num" v-if="activeKey == '3'">{{
          orderStatisticsInfo ? orderStatisticsInfo.fmtOrderTotalAmount : "0.00"
        }}</span>
        <span class="num symbol" v-if="activeKey == '4' || activeKey == '5'">{{
          refundStatisticsInfo ? refundStatisticsInfo.refundTotalCount : "0"
        }}</span>
        <span class="num symbol" v-if="activeKey == '6' || activeKey == '7'">{{
          enterpriseStatisticsInfo
            ? enterpriseStatisticsInfo.transferTotalCount
            : "0"
        }}</span>
        <span
          v-if="
            activeKey == '4' ||
            activeKey == '5' ||
            activeKey == '6' ||
            activeKey == '7'
          "
        >
          笔</span
        >
      </span>
      <span class="numBox" v-if="activeKey == '1'">
        <span>月手续费总额</span>
        <span class="symbol">￥</span>
        <span class="num">{{
          financialStatisticsInfo.fmtFeeTotalAmount || "0.00"
        }}</span>
      </span>
      <span class="numBox" v-if="activeKey == '2'">
        <span>优惠总额</span>
        <span class="symbol">￥</span>
        <span class="num">{{
          orderStatisticsInfo1
            ? orderStatisticsInfo1.fmtDiscountTotalAmount
            : "0.00"
        }}</span>
      </span>
      <span class="numBox" v-if="activeKey == '2'">
        <span>已退款</span>
        <span class="symbol">￥</span>
        <span class="num">{{
          orderStatisticsInfo1
            ? orderStatisticsInfo1.fmtRefundTotalAmount
            : "0.00"
        }}</span>
      </span>

      <span class="numBox" v-if="activeKey == '3'">
        <span>已支付</span>
        <span class="symbol">￥</span>
        <span class="num">{{
          orderStatisticsInfo ? orderStatisticsInfo.fmtPayTotalAmount : "0.00"
        }}</span>
      </span>

      <span class="numBox" v-if="activeKey == '3' || activeKey == '5'">
        <span>已退款</span>
        <span class="symbol">￥</span>
        <span class="num">{{
          activeKey == "3"
            ? orderStatisticsInfo
              ? orderStatisticsInfo.fmtRefundTotalAmount
              : "0.00"
            : activeKey == "4" || activeKey == "5"
            ? refundStatisticsInfo
              ? refundStatisticsInfo.fmtFinishRefundTotalAmount
              : "0.00"
            : "0.00"
        }}</span>
      </span>
      <!-- <span class="numBox" v-if="activeKey == '6' || activeKey == '7'">
        <span>已付款总额</span>
        <span class="symbol">￥</span>
        <span class="num">{{
          activeKey == "6" || activeKey == "7"
            ? enterpriseStatisticsInfo
              ? enterpriseStatisticsInfo.fmtFinishBalancePayTotalAmount
              : "0.00"
            : "0.00"
        }}</span>
      </span> -->
    </el-card>

    <el-card style="margin-top: 20px; min-width: 1200px">
      <div
        class="switch"
        v-if="activeKey == '2' || activeKey == '3' || activeKey == '5'"
      >
        <div>
          <el-switch v-model="isFixedTableH" inactive-text="固定表头">
          </el-switch>
          <!-- <el-switch
            class="ml"
              v-model="onlyShowSelf"
              inactive-text="仅展示商户自身数据">
          </el-switch> -->
        </div>
        <div>
          <el-button
            v-if="isTep == 1 && calcuRefund(dataList)"
            @click="handleClick"
            type="primary"
            class="width120"
            >批量处理</el-button
          >
          <div v-if="isTep == 2">
            <el-button @click="resetClick" class="width120">取消</el-button>
            <el-button type="primary" class="width120" @click="refundAll"
              >批量退款</el-button
            >
            <!-- <el-button type="danger" class="width120">批量拒绝</el-button> -->
          </div>
        </div>
        <!-- <el-button type="primary" v-if="activeKey == '1'" style="width: 168px">月报表下载</el-button> -->
      </div>
      <el-table
        v-if="activeKey == '1'"
        :data="dataList"
        :height="fixedTableHeight"
      >
        <template slot="empty">
          <el-empty
            :image="require('@/assets/imgs/middleWork/k1.png')"
            :image-size="80"
            description="暂无相关数据"
          ></el-empty>
        </template>
        <el-table-column
          show-overflow-tooltip
          prop="date"
          align="center"
          label="创建时间"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.date ? scope.row.date : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="incomeAmountTotal"
          sortable
          align="center"
          label="收入/元"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{
                Number(scope.row.fmtIncomeTotalAmount)
                  ? scope.row.fmtIncomeTotalAmount
                  : "0.00"
              }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="payoutAmountTotal"
          sortable
          align="center"
          label="支出/元"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{
                Number(scope.row.fmtPayoutTotalAmount)
                  ? scope.row.fmtPayoutTotalAmount
                  : "0.00"
              }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="payoutAmountTotal"
          sortable
          align="center"
          label="手续费/元"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{
                Number(scope.row.fmtFeeTotalAmount)
                  ? scope.row.fmtFeeTotalAmount
                  : "0.00"
              }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="date"
          align="center"
          label="日报表"
        >
          <template slot-scope="scope">
            <div v-if="scope.row.date == newDate">当日报表于次日生成</div>
            <div v-else>
              <div
                v-if="
                  !Number(scope.row.payoutAmountTotal) &&
                  !Number(scope.row.incomeAmountTotal)
                "
              >
                -
              </div>
              <el-button
                v-else
                @click="downFn(scope.row)"
                v-throttle="1000"
                type="primary"
                class="tableBtn"
                >下载</el-button
              >
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="address"
          align="center"
          label="渠道对账单"
        >
          <template slot-scope="scope">
            <div v-if="scope.row.groupTime == newDate">
              当日报表于次日12:00生成
            </div>
            <div v-else>
              <div
                v-if="
                  !Number(scope.row.totalIncomeAmount) &&
                  !Number(scope.row.totalPayoutAmount)
                "
              >
                -
              </div>
              <el-button
                v-else
                @click="channelDownFn(scope.row)"
                v-throttle="1000"
                type="primary"
                class="tableBtn"
                :disabled="scope.row.channelBillFileCreated == false"
                >下载</el-button
              >
            </div>
          </template>
        </el-table-column>
      </el-table>
      <!-- 业务订单 -->
      <el-table
        v-if="activeKey == '2'"
        :data="dataList"
        :height="fixedTableHeight"
        @selection-change="handleSelectionChange"
      >
        <template slot="empty">
          <el-empty
            :image="require('@/assets/imgs/middleWork/k1.png')"
            :image-size="80"
            description="暂无相关数据"
          ></el-empty>
        </template>
        <el-table-column
          show-overflow-tooltip
          prop="gmtCreated"
          width="180"
          align="center"
          label="创建时间"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.gmtCreated ? scope.row.gmtCreated : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="payformNo"
          align="center"
          label="商户订单号"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.merchantOrderNo ? scope.row.merchantOrderNo : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="subject"
          align="center"
          label="商品名称"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.subject ? scope.row.subject : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="memberName"
          align="center"
          label="收款方"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.memberName ? scope.row.memberName : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="fmtActualAmount"
          align="center"
          label="订单金额/元"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{
                scope.row.fmtOriginalAmount ? scope.row.fmtOriginalAmount : "-"
              }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="fmtRefundAmount"
          align="center"
          label="退款金额/元"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{
                scope.row.fmtRefundAmount ? scope.row.fmtRefundAmount : "0.00"
              }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="status"
          align="center"
          label="订单状态"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              <span :class="setPayStatus(scope.row.status).color">
                {{ setPayStatus(scope.row.status).str }}
              </span>
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="address"
          align="center"
          label="操作"
        >
          <template slot-scope="scope">
            <el-button type="text" @click="fetchApiDetail(scope.row)"
              >详情</el-button
            >
            <el-button
              type="text"
              v-if="
                scope.row.payStatus == 'wait_pay' &&
                scope.row.payformChannel != 'union' &&
                scope.row.payformChannel != 'douyin'
              "
              @click="cancelOrder(scope.row)"
              >取消订单</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <!-- 支付订单 -->
      <el-table
        v-if="activeKey == '3'"
        :data="dataList"
        :height="fixedTableHeight"
        @selection-change="handleSelectionChange"
        ref="multipleTable"
        :key="activeKey"
      >
        <template slot="empty">
          <el-empty
            :image="require('@/assets/imgs/middleWork/k1.png')"
            :image-size="80"
            description="暂无相关数据"
          ></el-empty>
        </template>
        <el-table-column
          v-if="activeKey == '3' && isPatch"
          type="selection"
          width="55"
          :selectable="(row) => row.refundIsDisplay"
        >
        </el-table-column>

        <el-table-column
          show-overflow-tooltip
          prop="gmtCreated"
          align="center"
          label="创建时间"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.gmtCreated ? scope.row.gmtCreated : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="gmtCreated"
          align="center"
          label="支付时间"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.payTime ? scope.row.payTime : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="payformNo"
          align="center"
          label="商户订单号"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{
                scope.row.merchantChargeNo ? scope.row.merchantChargeNo : "-"
              }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="subject"
          align="center"
          label="商品名称"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.subject ? scope.row.subject : "-" }}
            </div>
          </template>
        </el-table-column>
        <!-- <el-table-column
          show-overflow-tooltip
          prop="memberName"
          align="center"
          label="收款方"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.memberName ? scope.row.memberName : "-" }}
            </div>
          </template>
        </el-table-column> -->
        <el-table-column
          show-overflow-tooltip
          prop="fmtActualAmount"
          sortable
          align="center"
          label="支付金额/元"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{
                scope.row.fmtActualAmount ? scope.row.fmtActualAmount : "0.00"
              }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="channelPayFormTypeName"
          align="center"
          label="支付渠道"
        >
          <template slot-scope="scope">
            <span
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
              >{{ scope.row.channelName ? scope.row.channelName : "-" }}</span
            >
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="payStatusName"
          align="center"
          label="支付状态"
        >
          <template slot-scope="scope">
            <span
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
              >{{ scope.row.statusName ? scope.row.statusName : "-" }}</span
            >
          </template>
        </el-table-column>
        <!-- <el-table-column
          show-overflow-tooltip
          prop="settleMode"
          align="center"
          label="分账模式"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{
                scope.row.settleMode == "no_settle"
                  ? "无分账"
                  : scope.row.settleMode == "actual_settle"
                  ? "实时分账"
                  : "延时分账"
              }}
            </div>
          </template>
        </el-table-column> -->
        <el-table-column
          show-overflow-tooltip
          prop="fmtRefundAmount"
          align="center"
          label="退款金额/元"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{
                scope.row.fmtRefundAmount ? scope.row.fmtRefundAmount : "0.00"
              }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="act"
          align="center"
          label="操作"
        >
          <template slot-scope="scope">
            <el-button type="text" @click="fetchApiDetail(scope.row)"
              >详情</el-button
            >
            <!-- <el-button
              type="text"
              v-if="scope.row.refundIsDisplay"
              @click="refundMoney(scope.row)"
              >退款</el-button
            > -->
          </template>
        </el-table-column>
      </el-table>
      <!-- 单笔退款 -->
      <el-table
        v-if="activeKey == '4'"
        :data="dataList"
        :height="fixedTableHeight"
      >
        <template slot="empty">
          <el-empty
            :image="require('@/assets/imgs/middleWork/k1.png')"
            :image-size="80"
            description="暂无相关数据"
          ></el-empty>
        </template>
        <el-table-column
          show-overflow-tooltip
          prop="gmtCreated"
          align="center"
          label="创建时间"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.gmtCreated ? scope.row.gmtCreated : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="gmtCreated"
          align="center"
          label="完成时间"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.refundTime ? scope.row.refundTime : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="refundNo"
          align="center"
          label="云尘付流水号"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.innerRefundNo ? scope.row.innerRefundNo : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="refundNo"
          align="center"
          label="渠道流水号"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.thirdRefundNo ? scope.row.thirdRefundNo : "-" }}
            </div>
          </template>
        </el-table-column>
        <!-- <el-table-column
          show-overflow-tooltip
          prop="memberName"
          align="center"
          label="退款方"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.memberName ? scope.row.memberName : "-" }}
            </div>
          </template>
        </el-table-column> -->
        <el-table-column
          show-overflow-tooltip
          prop="fmtRefundAmount"
          align="center"
          sortable
          label="退款金额/元"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.refundAmountStr }}
            </div>
          </template>
        </el-table-column>
        <!-- <el-table-column
          show-overflow-tooltip
          prop="fmtRefundFeeAmount"
          align="center"
          sortable
          label="退款手续费/元"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{
                scope.row.fmtRefundFeeAmount
                  ? scope.row.fmtRefundFeeAmount
                  : "0.00"
              }}
            </div>
          </template>
        </el-table-column> -->
        <el-table-column
          show-overflow-tooltip
          prop="channelPayFormTypeName"
          align="center"
          label="支付渠道"
        >
          <template slot-scope="scope">
            <span
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
              >{{ scope.row.payChannelName }}</span
            >
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="refundStatus"
          align="center"
          label="退款状态"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              <span :class="setRefundStatus(scope.row.refundStatus).color">{{
                setRefundStatus(scope.row.refundStatus).str
              }}</span>
            </div>
          </template>
        </el-table-column>

        <el-table-column
          show-overflow-tooltip
          prop="act"
          align="center"
          label="操作"
        >
          <template slot-scope="scope">
            <!-- <el-button @click="handleClick(scope.row)" type="primary" class="tableBtn">重新发送</el-button> -->
            <el-button @click="fetchApiDetail(scope.row)" type="text"
              >详情</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <!-- 红包 -->
      <el-table
        v-if="activeKey == '5'"
        :data="dataList"
        :height="fixedTableHeight"
      >
        <template slot="empty">
          <el-empty
            :image="require('@/assets/imgs/middleWork/k1.png')"
            :image-size="80"
            description="暂无相关数据"
          ></el-empty>
        </template>
        <el-table-column
          show-overflow-tooltip
          prop="gmtCreated"
          align="center"
          label="创建时间"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.gmtCreated ? scope.row.gmtCreated : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="redNo"
          align="center"
          label="商户订单号"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.redNo ? scope.row.redNo : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="subject"
          align="center"
          label="活动名称"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.subject ? scope.row.subject : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="fmtAmount"
          align="center"
          label="红包金额/元"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.fmtAmount ? scope.row.fmtAmount : "0.00" }}
            </div>
          </template>
        </el-table-column>

        <el-table-column
          show-overflow-tooltip
          prop="channel"
          align="center"
          label="支付渠道"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.channelName ? scope.row.channelName : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="status"
          align="center"
          label="红包状态"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
              :style="{
                color:
                  scope.row.status == 'sending' || scope.row.status == 'send'
                    ? '#EE8917'
                    : scope.row.status == 'failed'
                    ? '#E23D28'
                    : '',
              }"
            >
              {{ scope.row.status ? setPayStatus1(scope.row.status) : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="act"
          align="center"
          label="操作"
          width="100"
        >
          <template slot-scope="scope">
            <el-button type="text" @click="fetchApiDetail(scope.row)"
              >详情</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <!-- <el-table
        v-if="activeKey == '5'"
        :data="dataList"
        :height="fixedTableHeight"
      >
        <template slot="empty">
          <el-empty
            :image="require('@/assets/imgs/middleWork/k1.png')"
            :image-size="80"
            description="暂无相关数据"
          ></el-empty>
        </template>
        <el-table-column
          show-overflow-tooltip
          prop="gmtCreated"
          align="center"
          label="创建时间"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.gmtCreated ? scope.row.gmtCreated : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="batchNo"
          align="center"
          label="退款批次号"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.batchNo ? scope.row.batchNo : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="fmtTotalRefundAmount"
          align="center"
          label="退款总金额/元"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{
                scope.row.fmtTotalRefundAmount
                  ? scope.row.fmtTotalRefundAmount
                  : "0.00"
              }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="fmtTotalRefundFeeAmount"
          align="center"
          label="退款总手续费/元"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{
                scope.row.fmtTotalRefundFeeAmount
                  ? scope.row.fmtTotalRefundFeeAmount
                  : "0.00"
              }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="orderCount"
          align="center"
          label="退款总笔数/笔"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              <span>{{
                scope.row.orderCount ? scope.row.orderCount : "-"
              }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="refundStatus"
          align="center"
          label="退款状态"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              <span :class="setRefundStatus1(scope.row.refundStatus).color">{{
                setRefundStatus1(scope.row.refundStatus).str
              }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="address"
          align="center"
          label="操作"
        >
          <template slot-scope="scope">
            <el-button type="text" @click="fetchApiDetail(scope.row)"
              >详情</el-button
            >
          </template>
        </el-table-column>
      </el-table> -->
      <!-- 企业付款 -->
      <el-table
        v-if="activeKey == '6'"
        :height="fixedTableHeight"
        :data="dataList"
      >
        <template slot="empty">
          <el-empty
            :image="require('@/assets/imgs/middleWork/k1.png')"
            :image-size="80"
            description="暂无相关数据"
          ></el-empty>
        </template>
        <el-table-column
          show-overflow-tooltip
          prop="gmtCreated"
          align="center"
          label="创建时间"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.gmtCreated ? scope.row.gmtCreated : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="orderNo"
          align="center"
          label="商户订单号"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.orderNo ? scope.row.orderNo : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="orderNo"
          align="center"
          label="批次号"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.batchNo ? scope.row.batchNo : "-" }}
            </div>
          </template>
        </el-table-column>
        <!-- <el-table-column
          show-overflow-tooltip
          prop="inAccountName"
          align="center"
          label="收款方"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.inAccountName ? scope.row.inAccountName : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="outMemberName"
          align="center"
          label="付款方"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.outMemberName ? scope.row.outMemberName : "-" }}
            </div>
          </template>
        </el-table-column> -->
        <el-table-column
          show-overflow-tooltip
          prop="fmtTransAmt"
          align="center"
          label="付款金额/元"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.fmtTransAmt ? scope.row.fmtTransAmt : "0.00" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="payformChannel"
          align="center"
          label="付款渠道"
        >
          <template slot-scope="scope">
            <span
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
              >{{
                scope.row.payformChannel
                  ? CHANNEL_TYPE[scope.row.payformChannel]
                  : "-"
              }}</span
            >
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="status"
          align="center"
          label="付款状态"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
              :class="setAuditStatus(scope.row.status).color"
            >
              {{ setAuditStatus(scope.row.status).str }}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="act" width="200" align="center" label="操作">
          <template slot-scope="scope">
            <el-button type="text" @click="fetchApiDetail(scope.row)"
              >详情</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <!-- 企业批量 -->
      <el-table
        v-if="activeKey == '7'"
        :height="fixedTableHeight"
        :data="dataList"
      >
        <template slot="empty">
          <el-empty
            :image="require('@/assets/imgs/middleWork/k1.png')"
            :image-size="80"
            description="暂无相关数据"
          ></el-empty>
        </template>
        <el-table-column
          show-overflow-tooltip
          prop="gmtCreated"
          align="center"
          label="创建时间"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.gmtCreated ? scope.row.gmtCreated : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="merBatchNo"
          align="center"
          label="批次号"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.merBatchNo ? scope.row.merBatchNo : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="totalNum"
          align="center"
          label="付款总笔数/笔"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.totalNum ? scope.row.totalNum : "-" }}</span>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="memberName"
          align="center"
          label="付款方"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.memberName ? scope.row.memberName : "-" }}</span>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="fmtTotalAmount"
          align="center"
          label="付款总金额/元"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.fmtTotalAmount ? scope.row.fmtTotalAmount : "0.00" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="commandForm.channel"
          align="center"
          label="付款渠道"
        >
          <template slot-scope="scope">
            <span
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
              >{{
                scope.row.channel ? CHANNEL_TYPE[scope.row.channel] : "-"
              }}</span
            >
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="status"
          align="center"
          label="结果"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
              :class="setAuditStatus1(scope.row.status).color"
            >
              {{ setAuditStatus1(scope.row.status).str }}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="act" width="200" align="center" label="操作">
          <template slot-scope="scope">
            <el-button type="text" @click="fetchApiDetail(scope.row)"
              >详情</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <el-pagination
      v-if="activeKey !== '1'"
      layout="prev, pager, next, sizes, jumper"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="pageSize"
      :current-page="pageNum"
      :total="total"
      @current-change="pageCurrentChangeHandle"
      @size-change="pageSizeChangeHandle"
    >
    </el-pagination>

    <!-- 退款弹窗 -->
    <el-dialog
      title=""
      :visible="refundDialog"
      width="449px"
      class="tkDialog"
      :close-on-click-modal="false"
      :show-close="false"
    >
      <div class="dialogTitle">退款申请</div>
      <el-form
        :model="form"
        ref="refundForm"
        :rules="rules"
        label-position="top"
      >
        <el-form-item label="退款理由" prop="refundRemark">
          <el-input
            v-model="form.refundRemark"
            maxlength="30"
            placeholder="输入退款理由"
            autocomplete="off"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item
          :label="
            '退款金额 ' +
            ' (不可超过' +
            parseFloat(
              (refundRow.fmtActualAmount - refundRow.fmtRefundAmount).toFixed(2)
            ) +
            '元)'
          "
          prop="refundAmount"
          v-if="!isRefundAll"
        >
          <el-input
            type="number"
            v-model="form.refundAmount"
            placeholder="输入退款金额"
            :disabled="refundRow.settleMode != 'no_settle'"
            :step="0.01"
            oninput="if(isNaN(value)) { value = parseFloat(value) } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)}"
          >
            <template slot="append">元</template>
          </el-input>
        </el-form-item>
      </el-form>
      <br />
      <div style="font-size: 12px">说明：部分退款不超过10次</div>
      <div style="margin-left: 36px; font-size: 12px">
        分账订单不支持部分退款
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="refundDialog = false" class="width120"
          >取消</el-button
        >
        <el-button type="primary" class="width120" @click="confirmRefund"
          >确定</el-button
        >
      </div>
    </el-dialog>
    <!-- 详情抽屉 -->
    <detail-drawer
      :drawer.sync="drawer"
      :info="detailsInfo"
      :activeKey="activeKey"
    ></detail-drawer>

    <!-- 报表渠道选择弹窗 -->
    <el-dialog
      class="cardDialog"
      :visible.sync="chargeDia"
      :show-close="false"
      width="480px"
      top="30vh"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
    >
      <div class="tip">选择需要下载的渠道对账单</div>
      <el-form ref="cform" :rules="rules" :model="form1">
        <el-form-item prop="dChannel" label-position="top">
          <el-select
            v-model="form1.dChannel"
            placeholder="请选择"
            class="width512"
          >
            <!-- <el-option
              label="汇付"
              value="ada"
              v-if="getUserInfo().userType != 'sub_admin'"
            >
            </el-option> -->
            <el-option label="微信" value="wechat"> </el-option>
            <el-option label="支付宝" value="ali"> </el-option>
            <!-- <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option> -->
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cencelReset">取消</el-button>
        <el-button type="primary" @click="handleSubmit">确认</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import mixins from "@/mixins/mixin";
import detailDrawer from "./detailDrawer.vue";
import { isAmount } from "@/utils/validate";
import { setTabIndex, getTabIndex } from "@/utils/public";
import { getUserInfo } from "@/utils/public";

export default {
  mixins: [mixins],
  name: "dealSearch",
  components: {
    detailDrawer,
  },
  data() {
    const verifyAmount = (rule, value, callback) => {
      if (value.length <= 0) {
        callback(new Error("请输入退款金额"));
      } else if (Number(value) > Number(this.refundRow.fmtActualAmount)) {
        callback(new Error("不能大于支付金额"));
      } else {
        if (value > 0) {
          if (!isAmount(value)) {
            callback(new Error("金额必须为整数或者保留两位小数"));
          }
          callback();
        } else {
          callback(new Error("金额必须大于0"));
        }
      }
    };
    return {
      chargeDia: false,
      curRow: "",
      options: [
        {
          value: "ada",
          label: "汇付",
        },
        {
          value: "wechat",
          label: "微信",
        },
        {
          value: "ali",
          label: "支付宝",
        },
      ],
      pickerOptions: {
        disabledDate: (time) => {
          return this.checkTime(time);
        },
      },
      merchantList: [],
      eventTab: "1",
      refundRow: {},
      isPatch: false,
      isTep: 1, //表格按钮切换
      multipleSelection: [],
      refundIds: [],
      drawerOrderDetail1: {}, //支付订单详情
      expendRefund1: false,
      expendRefund2: false,
      drawerOrderDetail: {}, //批量退款详情
      expendRefund: false,
      buttonRole: false,
      drawer: false,
      detailsInfo: {},
      payformId: null,
      isRefundAll: false,
      refundDialog: false,
      form: {
        refundAmount: "",
      },
      form1: {
        dChannel: "",
      },
      rules: {
        dChannel: [
          { required: true, message: "请选择渠道", trigger: "change" },
        ],
        refundRemark: [
          { required: false, message: "请输入退款理由", trigger: "change" },
          {
            pattern: /^(?!\s+).*(?<!\s)$/,
            message: "格式有误",
            trigger: "change",
          },
        ],
        refundAmount: [
          { required: true, message: "请输入退款金额", trigger: "change" },
          { validator: verifyAmount, trigger: "change" },
        ],
      },
      newDate: this.$moment(new Date()).format("YYYY-MM-DD"),
      activeKey: this.$route.query.searchId ? "2" : getTabIndex(),
      mixinViewModuleOptions: {
        createdIsNeed: false,
      },
      commandForm: {
        settleMode: "",
        searchVal: this.$route.query.searchId ? this.$route.query.searchId : "", // 搜索框的值
        date: this.$moment().format("YYYY-MM"),
        date2: [],
        date3: [],
        date4: [],
        date5: [], //企业批量
        dateType: "create",
        dateType2: "create",
        merchant: [],
        memberId: "",
        payStatus: "",
        status: "",
        payformChannel: "",
        refundStatus: "",
        payType: "",
        refundState: "",
        auditStatus: "",
        transactioType: "",
      },
      transactiotypeList: [
        { id: 1, label: "所有", value: "" },
        { id: 2, label: "支付", value: "order" },
        { id: 3, label: "退款", value: "refund" },
        { id: 4, label: "余额结算", value: "settle" },
        { id: 5, label: "企业付款", value: "transfer" },
        { id: 6, label: "充值", value: "charge" },
      ],
      financialStatisticsInfo: {
        incomeAmountTotal: 0,
        payoutAmountTotal: 0,
      },
      orderStatisticsInfo1: {
        originalAmount: "0.00",
        actualAmount: "0.00",
        refundAmount: "0.00",
      },
      orderStatisticsInfo: {
        originalAmount: "0.00",
        actualAmount: "0.00",
        refundAmount: "0.00",
      },
      refundStatisticsInfo: {},
      enterpriseStatisticsInfo: {},
      merchant: [], // 所属商户
      merchaList: [],
      refundStateList: [
        { id: 1, label: "所有", value: "" },
        { id: 2, label: "待退款", value: "waiting" },
        { id: 3, label: "处理中", value: "pending" },
        { id: 4, label: "退款成功", value: "success" },
        { id: 5, label: "退款失败", value: "fail" },
      ],
      refundStateList1: [
        { id: 1, label: "所有", value: "" },
        { id: 2, label: "处理中", value: "wait_refund" },
        { id: 3, label: "退款完成", value: "success_refund" },
      ],
      settleModeList: [
        { id: 1, label: "所有", value: "" },
        { id: 2, label: "无分账", value: "no_settle" },
        { id: 3, label: "实时分账", value: "actual_settle" },
        { id: 4, label: "延时分账", value: "delay_settle" },
      ],
      orderStateList: [
        // 订单状态
        { id: 1, label: "所有", value: "" },
        { id: 2, label: "已创建", value: "created" },
        { id: 3, label: "部分支付", value: "part_pay" },
        { id: 4, label: "支付完成", value: "finish" },
        // { id: 5, label: "支付失败", value: "fail_pay" },
        { id: 6, label: "支付取消", value: "cancel" },
      ],
      payStateList: [
        // 支付状态
        { id: 1, label: "所有", value: "" },
        { id: 2, label: "待支付", value: "created" },
        { id: 3, label: "支付中", value: "pending" },
        { id: 4, label: "支付成功", value: "success" },
        { id: 4, label: "支付失败", value: "fail" },
        { id: 4, label: "关闭订单", value: "close" },
      ],
      payStateList1: [
        // 付款状态
        { id: 1, label: "所有", value: "" },
        { id: 2, label: "处理中", value: "processing" },
        { id: 4, label: "处理成功", value: "success" },
        { id: 4, label: "处理失败", value: "fail" },
      ],
      redPackList: [
        // 红包状态
        { id: 1, label: "所有", value: "" },
        { id: 2, label: "发放中", value: "sending" },
        { id: 3, label: "发放待领取", value: "send" },
        { id: 4, label: "发放失败", value: "failed" },
        { id: 5, label: "已领取", value: "received" },
        { id: 6, label: "退款中", value: "rfunding" },
        { id: 7, label: "已退款", value: "refund" },
      ],
      refundCaseList: [
        // 退款状态
        { id: 1, label: "所有", value: "" },
        { id: 2, label: "无退款", value: "no_refund" },
        { id: 3, label: "部分退款", value: "part_refund" },
        { id: 4, label: "全额退款", value: "all_refund" },
      ],
      payChannel: [],
      // payChannel: this.$store.state.channelList,
      payChannelType: this.$store.state.channelListType,
      payChannelTypeList: [],
    };
  },
  created() {
    if (this.$store.state.buttonList) {
      this.$store.state.buttonList.forEach((e) => {
        if (e.type == "refund") {
          this.buttonRole = true;
        }
      });
      // console.log(this.buttonRole)
    }
    if (!this.commandForm.payformChannel) {
      this.payChannelTypeList = [{ label: "所有", value: "" }];
    }
    if (Object.keys(this.$route.query).length) {
      this.commandForm.searchVal = this.$route.query.searchId;
      this.activeKey = "3";
      setTabIndex(this.activeKey);
      this.dataForm = JSON.parse(JSON.stringify(this.commandForm));

      this.globalQuery();
    } else {
      this.tabClick();
    }

    this.getChannelList();
  },
  watch: {
    "$route.query"() {
      if (this.$route.query.searchId) {
        this.commandForm.searchVal = this.$route.query.searchId;
        this.activeKey = "3";
        setTabIndex(this.activeKey);
        this.dataForm = JSON.parse(JSON.stringify(this.commandForm));
        this.globalQuery();
        setTimeout(() => {
          this.$router.push(this.$route.path);
        }, 0);
      }
    },
    "$store.state.testLine": {
      handler() {
        if (this.$route.name == this.$options.name) {
          this.handleQuery();
        }
      },
    },
    deep: true,
  },
  methods: {
    getUserInfo,
    getTabIndex,
    getChannelList() {
      this.$http.get("/api/dict/channelList").then((res) => {
        if (res.code === "0000") {
          var a = [{ label: "所有", value: "" }];
          var b = a.concat(res.data);
          this.payChannel = b;
        }
      });
    },
    cencelReset() {
      this.chargeDia = false;
      this.$refs.cform.resetFields(); //重置状态
    },
    handleSubmit() {
      if (
        this.curRow &&
        (this.curRow.payformChannel == null || this.curRow.payformChannel == "")
      ) {
        this.$refs.cform.validate((valid) => {
          if (valid) {
            this.downFile(this.form1.dChannel);
          } else {
            return false;
          }
        });
      } else {
        this.downFile(this.curRow.payformChannel);
      }
    },
    downFile(channel) {
      console.log(this.curRow);
      this.$http
        .post(`/api/bill/downloadCenter/createChannelBill`, {
          billDate: this.curRow.date,
          payformChannel: channel,
          memberId: this.curRow.memberId || "",
          dataType: "sub_member",
        })
        .then((res) => {
          if (res.code === "0000") {
            this.$message.success("已添加到下载中心！");
            this.cencelReset();
          }
        });
    },
    exchangeEventTab() {
      if (this.eventTab == "1") {
        this.eventTab = "2";
        this.dataForm = JSON.parse(JSON.stringify(this.commandForm));
        this.globalQuery();
      } else {
        this.eventTab = "1";
        this.tabClick();
        // this.handleQuery();
      }
    },
    //详情页请求汇总
    fetchApiDetail(row) {
      console.log(row);
      switch (this.activeKey) {
        case "2":
          //业务订单
          this.$http
            .get(`/api/order/merchant/detail?id=${row.id}`)
            .then((res) => {
              if (res.code === "0000") {
                this.detailsInfo = res.data;
                this.drawer = true;
              }
            });
          break;
        case "3":
          //支付订单
          this.$http
            .get(`/api/charge/merchant/detail?id=${row.id}`)
            .then((res) => {
              if (res.code === "0000") {
                this.detailsInfo = res.data;
                this.drawer = true;
              }
            });
          break;
        case "4":
          //单笔退款
          this.$http
            .get(`/api/orderInfo/getRefundById?id=${row.id}`)
            .then((res) => {
              if (res.code === "0000") {
                console.log(res.data);
                this.detailsInfo = res.data;
                this.drawer = true;
              }
            });
          break;
        case "5":
          //红包
          this.$http
            .get(
              `/api/merchant/redPacketInfo/get?id=${row.id}`
            )
            .then((res) => {
              if (res.code === "0000") {
                console.log(res.data);
                this.detailsInfo = res.data;
                this.drawer = true;
              }
            });
          break;
        case "6":
          //企业付款
          this.$http
            .get(`/api/transfer/merchant/detail?id=${row.id}`)
            .then((res) => {
              if (res.code === "0000") {
                console.log(res.data);
                this.detailsInfo = res.data;
                this.drawer = true;
              }
            });
          break;
        case "7":
          //企业批量
          this.$http
            .get(`/api/merchant/settleBalancePay/searchBatchById?id=${row.id}`)
            .then((res) => {
              if (res.code === "0000") {
                console.log(res.data);
                this.detailsInfo = res.data;
                this.drawer = true;
              }
            });
          break;
        default:
          break;
      }
    },
    //重置操作
    resetFields() {
      // this.resetForm("dealSearchForm");
      this.commandForm = {
        memberId: null,
        searchVal: this.commandForm.searchVal,
        status: "",
        settleMode: "",
        date: "",
        date2: [],
        date3: [],
        date4: [],
        date5: [],
        dateType: "create",
        dateType2: "create",
        merchant: [],
        payStatus: "",
        payformChannel: "",
        refundStatus: "",
        payType: "",
        refundState: "",
        auditStatus: "",
        transactioType: "",
      };
    },
    calcuRefund(list) {
      let bthchTag = false;
      list &&
        list.length &&
        list.map((item) => {
          if (item.refundIsDisplay) {
            bthchTag = true;
            return;
          }
        });
      return bthchTag;
    },
    changeValue(value) {
      //console.log(value);
      let obj = this.merchantList.find(function (item) {
        return item.id === value;
      });
      console.log(obj);
      // this.form.inMemberId = value.id;
      this.commandForm.memberId = obj ? obj.id : null;
    },
    setId1() {
      if (this.merchantList.length != 0) {
        this.merchantList = [];
      }
    },
    remoteMethod(query) {
      if (query !== "") {
        this.getMerchantList(query);
      } else {
        this.merchantList = [];
      }
    },
    getMerchantList(val) {
      let url = "";
      if (
        this.activeKey == "3" ||
        this.activeKey == "4" ||
        this.activeKey == "5"
      ) {
        //支付订单，退款，批量退款
        url = `/api/merchant/memberbase/getMemberNotUserByMemberName?memberName=${val}&includeSelf=N`;
      } else {
        url = `/api/merchant/memberbase/getMemberBaseByAppIdMemberName?memberName=${val}`;
      }
      this.$http.get(`${url}`).then((res) => {
        if (res.code === "0000") {
          this.merchantList = res.data;
        }
      });
    },
    setAuditStatus1(val) {
      let color = "";
      let str = "";
      switch (val) {
        case "applying":
          str = "申请中";
          color = "pedding";
          break;
        case "applied":
          str = "申请成功";
          color = "succeed";
          break;
        case "applyFail":
          str = "申请失败";
          color = "failed";
          break;
        case "all_fail":
          str = "失败";
          color = "failed";
          break;
        case "all_sucess":
          str = "成功";
          color = "succeed";
          break;
        case "part_sucess":
          str = "部分成功";
          color = "succeed";
          break;
      }
      return {
        str,
        color,
      };
    },
    refundAll() {
      if (this.multipleSelection.length === 0) {
        return this.$message.warning("请先选择退款订单");
      } else {
        let that = this;
        that
          .$confirm(
            "确认退款后，无需审核的将直接发起退款，需要审核的需审核人同意后方可发起退款，审核人拒绝则该笔订单状态不变，退款成功后退款金额将于7个工作日内原路原回。",
            "确认执行",
            {
              customClass: "confirm",
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              showClose: false,
              closeOnClickModal: false,
              closeOnPressEscape: false,
              type: "warning",
              center: true,
            }
          )
          .then(() => {
            that.refundIds = that.multipleSelection.map((item) => item.id);
            that.refundDialog = true;
            that.isRefundAll = true;
            that.form = {
              refundRemark: "",
              refundAmount: "",
            };
            setTimeout(() => {
              that.$refs.refundForm.clearValidate(["refundRemark"]);
            }, 0);
          });
      }
    },
    checkTime(time) {
      // let t = new Date().getDate();
      // 如果想包含本月本月 - 8.64e7 * t 就不需要了，
      // 如果想之前的不能选择把 > 换成 <
      return time.getTime() > Date.now();
    },
    //企业付款详情
    handleDetailsToPage(rowData, type) {
      this.$router.push({
        path: "/merchant/dealSearch/detail",
        query: { id: rowData.id, type },
      });
    },
    handleClick() {
      this.$refs.multipleTable.clearSelection();

      this.isPatch = true;
      this.isTep = 2;
    },
    resetClick() {
      this.isPatch = false;
      this.multipleSelection = [];
      // this.$refs.multipleTable.clearSelection();
      this.isTep = 1;
      //console.log(this.multipleSelection);
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
      //console.log(this.multipleSelection);
    },
    // handleDetails1(row) {
    //   // 订单详情
    //   this.$router.push({
    //     path: "/merchant/dealSearch/detailPay",
    //     query: { id: row.id },
    //   });
    // },
    setAuditStatus(val) {
      let color = "";
      let str = "";
      switch (val) {
        case "processing":
          str = "处理中";
          color = "pedding";
          break;
        case "success":
          str = "处理成功";
          color = "succeed";
          break;
        case "fail":
          str = "处理失败";
          color = "failed";
          break;
      }
      return {
        str,
        color,
      };
    },
    handleDetails(row) {
      //退款
      if (this.activeKey == "4") {
        this.$router.push({
          path: "/merchant/dealSearch/detailRefund",
          query: { id: row.id, type: "1" },
        });
      } else if (this.activeKey == "5") {
        this.$router.push({
          path: "/marketingTool/weChatRedPacket/detail",
          query: { id: row.id },
        });
        // this.$router.push({
        //   path: "/merchant/dealSearch/detailRefund",
        //   query: { id: row.batchNo, type: "2" },
        // });
      }
    },
    // 退款
    refundMoney(row) {
      let that = this;
      that
        .$confirm(
          "确认退款后，无需审核的将直接发起退款，需要审核的需审核人同意后方可发起退款，审核人拒绝则该笔订单状态不变，退款成功后退款金额将于7个工作日内原路原回。",
          "确认执行",
          {
            customClass: "confirm",
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            showClose: false,
            closeOnClickModal: false,
            closeOnPressEscape: false,
            type: "warning",
            center: true,
          }
        )
        .then(() => {
          that.refundRow = row;
          that.form = {
            refundRemark: "",
            refundAmount: "",
          };
          if (that.refundRow.settleMode != "no_settle") {
            that.form.refundAmount = that.refundRow.fmtActualAmount;
          } else {
            that.form.refundAmount = "";
          }
          that.payformId = row.id;
          that.refundDialog = true;
          setTimeout(() => {
            that.$refs.refundForm.clearValidate([
              "refundRemark",
              "refundAmount",
            ]);
          }, 0);
          that.isRefundAll = false;
        });
    },
    confirmRefund() {
      this.$refs.refundForm.validate((valid) => {
        if (valid) {
          // 批量退款
          if (this.isRefundAll) {
            this.$http
              .post("/api/merchant/refundAudit/batchAdd", {
                ids: this.refundIds,
                refundRemark: this.form.refundRemark,
                onlyShowSelf: false,
              })
              .then((res) => {
                if (res.code === "0000") {
                  this.$message.success("已提交！");
                  this.refundDialog = false;
                  this.form.refundRemark = "";
                  this.getChargeList();
                  this.getChargeStatistics();
                }
              });
          } else {
            // 单笔退款
            this.$http
              .post("/api/merchant/refundAudit/add", {
                payformId: this.payformId,
                refundRemark: this.form.refundRemark,
                refundAmt: this.form.refundAmount,
                onlyShowSelf: false,
              })
              .then((res) => {
                if (res.code === "0000") {
                  this.$message.success("已提交！");
                  this.refundDialog = false;
                  this.form.refundRemark = "";
                  this.getChargeList();
                  this.getChargeStatistics();
                }
              });
          }
        }
      });
    },
    downFn(row) {
      this.$http
        .post(`/api/bill/downloadCenter/createYuncnBill`, {
          billDate: row.date,
          dataType: "sub_members",
          billType: "yuncnpay",
          memberId: row.memberId,
        })
        .then((res) => {
          if (res.code === "0000") {
            this.$message.success("已添加到下载中心！");
          }
        });
    },
    channelDownFn(row) {
      //未选择渠道
      if (row.payformChannel == null || row.payformChannel == "") {
        console.log(1);
        this.chargeDia = true;
        this.curRow = row;
      } else {
        console.log(2);
        //已选渠道
        this.curRow = row;
        this.handleSubmit();
      }
    },
    tabClick() {
      this.dataList = [];
      setTabIndex(this.activeKey);
      this.eventTab = "1";
      this.resetClick();
      this.resetFields();
      this.commandForm.searchVal = ""; // 搜索框的值

      //获取应用列表信息
      this.$http.get("/api/app/get").then((res) => {
        let appItem = res.data.find(
          (item) => item.id == this.$store.state.appId
        );
        this.merchaList = [
          {
            id: "",
            memberName: appItem.appName,
          },
        ];
        this.getmerList();
      });

      if (this.activeKey == "1") {
        this.commandForm.date = this.$moment().format("YYYY-MM");
      } else if (this.activeKey == "2" || this.activeKey == "3") {
        this.commandForm.date2 = [
          this.$moment().startOf("day").format("YYYY-MM-DD HH:mm:ss"),
          this.$moment().endOf("day").format("YYYY-MM-DD HH:mm:ss"),
        ];
      } else if (this.activeKey == "4") {
        this.commandForm.date3 = [
          this.$moment().startOf("day").format("YYYY-MM-DD HH:mm:ss"),
          this.$moment().endOf("day").format("YYYY-MM-DD HH:mm:ss"),
        ];
      } else if (this.activeKey == "6") {
        this.commandForm.date4 = [
          this.$moment().startOf("day").format("YYYY-MM-DD HH:mm:ss"),
          this.$moment().endOf("day").format("YYYY-MM-DD HH:mm:ss"),
        ];
      } else if (this.activeKey == "5") {
        this.commandForm.date4 = [];
      } else {
        this.commandForm.date5 = [
          this.$moment().startOf("day").format("YYYY-MM-DD HH:mm:ss"),
          this.$moment().endOf("day").format("YYYY-MM-DD HH:mm:ss"),
        ];
      }
      this.dataForm = JSON.parse(JSON.stringify(this.commandForm));
      this.handleQuery();
    },
    getmerList() {
      this.$http
        .get("/api/merchant/memberbase/listByAppIdAndTreeChain")
        .then((res) => {
          this.merchaList = [...this.merchaList, ...res.data];
          // this.commandForm.memberId = this.$store.state.appId;
        });
    },
    tabClick1() {
      this.resetFields();
      if (this.activeKey == "1") {
        this.commandForm.date = this.$moment().format("YYYY-MM");
      } else if (this.activeKey == "3") {
        this.commandForm.date2 = [
          this.$moment().startOf("day").format("YYYY-MM-DD HH:mm:ss"),
          this.$moment().endOf("day").format("YYYY-MM-DD HH:mm:ss"),
        ];
      } else if (this.activeKey == "4" || this.activeKey == "5") {
        this.commandForm.date3 = [
          this.$moment().startOf("day").format("YYYY-MM-DD HH:mm:ss"),
          this.$moment().endOf("day").format("YYYY-MM-DD HH:mm:ss"),
        ];
      } else if (this.activeKey == "6") {
        this.commandForm.date4 = [
          this.$moment().startOf("day").format("YYYY-MM-DD HH:mm:ss"),
          this.$moment().endOf("day").format("YYYY-MM-DD HH:mm:ss"),
        ];
      } else {
        this.commandForm.date5 = [
          this.$moment().startOf("day").format("YYYY-MM-DD HH:mm:ss"),
          this.$moment().endOf("day").format("YYYY-MM-DD HH:mm:ss"),
        ];
      }
    },
    setRefundStatus(val) {
      let str = "";
      let color = "";
      switch (val) {
        // case 'wait_approval':
        //   str = '待审核'
        //   break;
        case "pending":
          str = "处理中";
          color = "pedding";
          break;
        case "waiting":
          str = "待退款";
          color = "pedding";
          break;
        case "success":
          str = "退款成功";
          color = "succeed";
          break;
        case "fail":
          str = "退款失败";
          color = "failed";
          break;
      }
      return {
        str,
        color,
      };
    },
    setRefundStatus1(val) {
      let str = "";
      let color = "";
      switch (val) {
        case "wait_refund":
          str = "处理中";
          color = "pedding";
          break;
        case "success_refund":
          str = "退款完成";
          color = "succeed";
          break;
      }
      return {
        str,
        color,
      };
    },
    setRefundState(val) {
      let str = "";
      switch (val) {
        case "no_refund":
          str = "无退款";
          break;
        case "part_refund":
          str = "部分退款";
          break;
        case "all_refund":
          str = "全额退款";
          break;
      }
      return str;
    },
    setPayStatus(val) {
      let str = "";
      let color = "";
      switch (val) {
        case "created":
          str = "已创建";
          color = "succeed";
          break;
        case "part_pay":
          str = "部分支付";
          color = "pedding";
          break;
        case "finish":
          str = "支付完成";
          color = "succeed";
          break;
        // case "fail_pay":
        //   str = "支付失败";
        //   color = "failed";
        //   break;
        case "cancel":
          str = "支付取消";
          color = "failed";
          break;
      }
      return {
        str,
        color,
      };
    },
    setPayStatus1(val) {
      let str = "";
      switch (val) {
        case "sending":
          str = "发放中";
          break;
        case "send":
          str = "发放待领取";
          break;
        case "failed":
          str = "发放失败";
          break;
        case "received":
          str = "已领取";
          break;
        case "rfunding":
          str = "退款中";
          break;
        case "refund":
          str = "已退款";
          break;
      }
      return str;
    },
    handleChannel(val) {
      if (val) {
        this.payChannelTypeList = this.payChannelType[val];
      } else {
        this.payChannelTypeList = [];
      }
      this.commandForm.payType = "";
    },
    // 财务汇总列表
    getFinancialList() {
      this.$http
        .post("/api/member/trade/financialList", {
          date: this.dataForm.date
            ? this.dataForm.date
            : this.$moment().format("YYYY-MM"),
          payformChannel: this.dataForm.payformChannel,
          payType: this.dataForm.payType,
          sourceMerchantIds: this.dataForm.merchant.length
            ? [this.dataForm.merchant.at(-1)]
            : [],
          subMemberId: this.dataForm.memberId,
        })
        .then((res) => {
          if (res.code == "0000") {
            this.dataList = res.data;
          } else {
            this.dataList = [];
          }
        });
    },
    // 财务汇总统计
    getFinancialStatistics() {
      this.$http
        .post("/api/member/trade/financialStatistics", {
          date: this.dataForm.date
            ? this.dataForm.date
            : this.$moment().format("YYYY-MM"),
          payformChannel: this.dataForm.payformChannel,
          payType: this.dataForm.payType,
          sourceMerchantIds: this.dataForm.merchant.length
            ? [this.dataForm.merchant.at(-1)]
            : [],
          subMemberId: this.dataForm.memberId,
        })
        .then((res) => {
          if (res.code == "0000") {
            this.financialStatisticsInfo = res.data;
          }
        });
    },
    // 业务订单
    getOrderList() {
      this.$http
        .post("/api/order/merchant/listByPage", {
          pageNum: this.pageNum,
          pageSize: this.pageSize,
          params: this.setOrderParams(),
        })
        .then((res) => {
          if (res.code == "0000") {
            //console.log(res.data);
            this.dataList = res.data.list;
            this.total = res.data.total;
          } else {
            this.dataList = [];
            this.total = 0;
          }
        });
    },
    // 支付订单列表
    getChargeList() {
      this.$http
        .post("/api/charge/merchant/listByPage", {
          pageNum: this.pageNum,
          pageSize: this.pageSize,
          params: this.setChargeParams(),
        })
        .then((res) => {
          if (res.code == "0000") {
            //console.log(res.data);
            this.dataList = res.data.list;
            this.total = res.data.total;
          } else {
            this.dataList = [];
            this.total = 0;
          }
        });
    },
    getOrderStatistics() {
      this.$http
        .post("/api/order/merchant/statistics", {
          ...this.setOrderParams(),
        })
        .then((res) => {
          if (res.code == "0000") {
            console.log(res.data);
            this.orderStatisticsInfo1 = res.data;
          }
        });
    },
    // 支付订单统计
    getChargeStatistics() {
      this.$http
        .post("/api/charge/merchant/statistics", {
          ...this.setChargeParams(),
          pay_status: "success_pay",
        })
        .then((res) => {
          if (res.code == "0000") {
            console.log(res.data);
            this.orderStatisticsInfo = res.data;
          }
        });
    },
    // 单笔退款统计
    getRefundStatistics() {
      this.$http
        .post("/api/orderInfo/refundStatistics", this.setRefundParams())
        .then((res) => {
          if (res.code == "0000") {
            console.log(res.data);
            this.refundStatisticsInfo = res.data;
          }
        });
    },
    // 批量退款统计
    getBtnchRefundStatistics() {
      this.$http
        .post("/api/orderInfo/batchRefundStatistics", this.setRefundParams())
        .then((res) => {
          if (res.code == "0000") {
            console.log(res.data);
            this.refundStatisticsInfo = res.data;
          }
        });
    },
    //企业付款统计
    getEnterpriseStatistics() {
      this.$http
        .post("/api/transfer/merchant/statistics", this.setEnterpriseParams())
        .then((res) => {
          if (res.code == "0000") {
            console.log(res.data);
            this.enterpriseStatisticsInfo = res.data;
          }
        });
    },
    //批量企业付款统计
    getBatchEnterpriseStatistics() {
      this.$http
        .post(
          "/api/merchant/settleBalancePay/batchBalancePayStatistics",
          this.setEnterpriseBatchParams()
        )
        .then((res) => {
          if (res.code == "0000") {
            console.log(res.data);
            this.enterpriseStatisticsInfo = res.data;
          }
        });
    },
    setRedPackParams() {
      let params = {
        gmtCreatedBegin: this.dataForm.date4 ? this.dataForm.date4[0] : null,
        gmtCreatedEnd: this.dataForm.date4 ? this.dataForm.date4[1] : null,
        status: this.dataForm.status ? this.dataForm.status : "",
        payformChannel: this.dataForm.payformChannel,
        payType: this.dataForm.payType,
        onlyShowSelf: false,
        memberId: this.dataForm.memberId ? this.dataForm.memberId : null,
      };
      return params;
    },
    setEnterpriseParams() {
      let params = {
        gmtCreatedBegin: this.dataForm.date4 ? this.dataForm.date4[0] : null,
        gmtCreatedEnd: this.dataForm.date4 ? this.dataForm.date4[1] : null,
        status: this.dataForm.status ? this.dataForm.status : "",
        payformChannel: this.dataForm.payformChannel,
        onlyShowSelf: false,
        memberId: this.dataForm.memberId ? this.dataForm.memberId : null,
      };
      return params;
    },
    setEnterpriseBatchParams() {
      let params = {
        gmtCreatedBegin: this.dataForm.date5 ? this.dataForm.date5[0] : null,
        gmtCreatedEnd: this.dataForm.date5 ? this.dataForm.date5[1] : null,
        channel: this.dataForm.payformChannel,
        onlyShowSelf: false,
      };
      return params;
    },
    setChargeParams() {
      if (this.eventTab == "2") {
        let params = {
          payformNo: this.dataForm.searchVal,
          orderType: "open_order",
          onlyShowSelf: false,
        };
        return params;
      } else {
        let params = {
          orderType: "open_order",
          onlyShowSelf: false,
          settleMode: this.dataForm.settleMode, //分账模式
          payStatus: this.dataForm.payStatus,
          status: this.dataForm.status,
          refundState: this.dataForm.refundState,
          payformChannel: this.dataForm.payformChannel,
          payType: this.dataForm.payType,
          sourceMerchantIds: this.dataForm.merchant.length
            ? [this.dataForm.merchant.at(-1)]
            : [],
          memberId: this.dataForm.memberId,
        };
        if (this.dataForm.date2 && this.dataForm.date2.length) {
          if (this.dataForm.dateType == "create") {
            params.createStartTime = this.dataForm.date2[0];
            params.createEndTime = this.dataForm.date2[1];
          } else {
            params.payStartTime = this.dataForm.date2[0];
            params.payEndTime = this.dataForm.date2[1];
          }
        } else {
          this.dataForm.date2 = [
            this.$moment().startOf("day").format("YYYY-MM-DD HH:mm:ss"),
            this.$moment().endOf("day").format("YYYY-MM-DD HH:mm:ss"),
          ];
          params.createStartTime = this.dataForm.date2[0];
          params.createEndTime = this.dataForm.date2[1];
        }
        return params;
      }
    },
    setOrderParams() {
      if (this.eventTab == "2") {
        let params = {
          payformNo: this.dataForm.searchVal,
          orderType: "open_order",
          onlyShowSelf: false,
        };
        return params;
      } else {
        let params = {
          // orderType: "open_order",
          // onlyShowSelf: false,
          // settleMode: this.dataForm.settleMode, //分账模式
          // payStatus: this.dataForm.payStatus,
          // refundState: this.dataForm.refundState,
          // payformChannel: this.dataForm.payformChannel,
          // payType: this.dataForm.payType,
          // sourceMerchantIds: this.dataForm.merchant.length
          //   ? [this.dataForm.merchant.at(-1)]
          //   : [],
          // memberId: this.dataForm.memberId,
        };
        if (this.dataForm.date2 && this.dataForm.date2.length) {
          if (this.dataForm.dateType == "create") {
            params.gmtCreatedBegin = this.dataForm.date2[0];
            params.gmtCreatedEnd = this.dataForm.date2[1];
          } else {
            params.payTimeBegin = this.dataForm.date2[0];
            params.payTimeEnd = this.dataForm.date2[1];
          }
        } else {
          this.dataForm.date2 = [
            this.$moment().startOf("day").format("YYYY-MM-DD HH:mm:ss"),
            this.$moment().endOf("day").format("YYYY-MM-DD HH:mm:ss"),
          ];
          params.gmtCreatedBegin = this.dataForm.date2[0];
          params.gmtCreatedEnd = this.dataForm.date2[1];
        }
        return params;
      }
    },
    setRefundParams() {
      if (this.eventTab == "2") {
        if (this.activeKey == "4") {
          let params = {
            refundNo: this.dataForm.searchVal,
            onlyShowSelf: false,
          };
          return params;
        } else {
          let params = {
            batchNo: this.dataForm.searchVal,
            onlyShowSelf: false,
          };
          return params;
        }
      } else {
        let params = {
          onlyShowSelf: false,
          payformChannel: this.dataForm.payformChannel,
          payType: this.dataForm.payType,
          refundStatus: this.dataForm.refundStatus,
          sourceMerchantIds: this.dataForm.merchant.length
            ? [this.dataForm.merchant.at(-1)]
            : [],
          auditStatus: this.dataForm.auditStatus
            ? this.dataForm.auditStatus
            : "",
          memberId: this.dataForm.memberId,
        };
        if (this.dataForm.date3 && this.dataForm.date3.length) {
          if (this.dataForm.dateType2 == "create") {
            params.gmtCreatedBegin = this.dataForm.date3
              ? this.dataForm.date3[0]
              : null;
            params.gmtCreatedEnd = this.dataForm.date3
              ? this.dataForm.date3[1]
              : null;
          } else {
            params.refundTimeBegin = this.dataForm.date3
              ? this.dataForm.date3[0]
              : null;
            params.refundTimeEnd = this.dataForm.date3
              ? this.dataForm.date3[1]
              : null;
          }
        } else {
          this.dataForm.date3 = [
            this.$moment().startOf("day").format("YYYY-MM-DD HH:mm:ss"),
            this.$moment().endOf("day").format("YYYY-MM-DD HH:mm:ss"),
          ];
          params.gmtCreatedBegin = this.dataForm.date3[0];
          params.gmtCreatedEnd = this.dataForm.date3[1];
        }
        return params;
      }
    },
    // 退款查询列表
    getRefundList() {
      this.$http
        .post("/api/refund/member/page", {
          pageNum: this.pageNum,
          pageSize: this.pageSize,
          params: this.setRefundParams(),
        })
        .then((res) => {
          if (res.code == "0000") {
            this.dataList = res.data.list;
            this.total = res.data.total;
          } else {
            this.dataList = [];
            this.total = 0;
          }
        });
    },
    getBatchRefundList() {
      this.$http
        .post("/api/merchant/redPacketInfo/searchByPage", {
          pageNum: this.pageNum,
          pageSize: this.pageSize,
          params: this.setRedPackParams(),
        })
        .then((res) => {
          if (res.code == "0000") {
            this.dataList = res.data.list;
            this.total = res.data.total;
          } else {
            this.dataList = [];
            this.total = 0;
          }
        });
    },
    getEnterpriseList() {
      this.$http
        .post("/api/transfer/merchant/listByPage", {
          pageNum: this.pageNum,
          pageSize: this.pageSize,
          params: this.setEnterpriseParams(),
        })
        .then((res) => {
          if (res.code == "0000") {
            //console.log(res.data);
            this.dataList = res.data.list;
            this.total = res.data.total;
          } else {
            this.dataList = [];
            this.total = 0;
          }
        });
    },
    //企业批量
    getEnterpriseBatchList() {
      this.$http
        .post("/api/merchant/settleBalancePay/searchBatchByPage", {
          pageNum: this.pageNum,
          pageSize: this.pageSize,
          params: this.setEnterpriseBatchParams(),
        })
        .then((res) => {
          if (res.code == "0000") {
            //console.log(res.data);
            this.dataList = res.data.list;
            this.total = res.data.total;
          } else {
            this.dataList = [];
            this.total = 0;
          }
        });
    },
    handleQuery() {
      this.eventTab = "1";
      this.dataForm.searchVal = "";
      this.pageNum = 1;
      this.pageSize = 10;
      if (this.activeKey == "1") {
        this.getFinancialList();
        this.getFinancialStatistics();
      } else if (this.activeKey == "2") {
        this.getOrderList();
        this.getOrderStatistics();
      } else if (this.activeKey == "3") {
        this.getChargeList();
        this.getChargeStatistics();
      } else if (this.activeKey == "4") {
        this.getRefundList();
        // this.getRefundStatistics();
      } else if (this.activeKey == "5") {
        this.getBatchRefundList();
        // this.getBtnchRefundStatistics();
      } else if (this.activeKey == "6") {
        //企业付款
        this.getEnterpriseList();
        this.getEnterpriseStatistics();
      } else {
        //企业批量
        this.getEnterpriseBatchList();
        this.getBatchEnterpriseStatistics();
      }
    },
    globalQuery() {
      this.eventTab = "2";
      this.tabClick1();
      this.pageNum = 1;
      this.pageSize = 10;

      if (this.activeKey == "1") {
        this.getFinancialList();
        this.getFinancialStatistics();
      } else if (this.activeKey == "3") {
        this.getChargeList();
        this.getChargeStatistics();
      } else if (this.activeKey == "4") {
        this.getRefundList();
        // this.getRefundStatistics();
      } else if (this.activeKey == "5") {
        this.getBatchRefundList();
        // this.getBtnchRefundStatistics();
      } else if (this.activeKey == "6") {
        //企业付款
        this.getEnterpriseList();
      } else {
        //企业批量
        this.getEnterpriseBatchList();
      }
    },
    // 分页, 每页条数
    pageSizeChangeHandle(val) {
      this.pageNum = 1;
      this.pageSize = val;
      if (this.activeKey == "2") {
        if (this.eventTab == "2") {
          this.tabClick1();
          this.commandForm.date2 = [];
        } else {
          this.commandForm.searchVal = "";
        }
        this.getOrderList();
      } else if (this.activeKey == "3") {
        if (this.eventTab == "2") {
          this.tabClick1();
          this.commandForm.date2 = [];
        } else {
          this.commandForm.searchVal = "";
        }
        this.getChargeList();
      } else if (this.activeKey == "4") {
        if (this.eventTab == "2") {
          this.tabClick1();
          this.commandForm.date3 = [];
        } else {
          this.commandForm.searchVal = "";
        }
        this.getRefundList();
      } else if (this.activeKey == "5") {
        if (this.eventTab == "2") {
          this.tabClick1();
          this.commandForm.date3 = [];
        } else {
          this.commandForm.searchVal = "";
        }
        this.getBatchRefundList();
      } else if (this.activeKey == "6") {
        //企业付款
        this.getEnterpriseList();
      } else {
        //批量
        this.getEnterpriseBatchList();
      }
    },
    // 分页, 当前页
    pageCurrentChangeHandle(val) {
      this.pageNum = val;
      if (this.activeKey == "2") {
        if (this.eventTab == "2") {
          this.tabClick1();
          this.commandForm.date2 = [];
        } else {
          this.commandForm.searchVal = "";
        }
        this.getOrderList();
      } else if (this.activeKey == "3") {
        if (this.eventTab == "2") {
          this.tabClick1();
          this.commandForm.date2 = [];
        } else {
          this.commandForm.searchVal = "";
        }
        this.getChargeList();
      } else if (this.activeKey == "4") {
        if (this.eventTab == "2") {
          this.tabClick1();
          this.commandForm.date3 = [];
        } else {
          this.commandForm.searchVal = "";
        }
        this.getRefundList();
      } else if (this.activeKey == "5") {
        if (this.eventTab == "2") {
          this.tabClick1();
          this.commandForm.date3 = [];
        } else {
          this.commandForm.searchVal = "";
        }
        this.getBatchRefundList();
      } else if (this.activeKey == "6") {
        //企业付款
        this.getEnterpriseList();
      } else {
        //企业批量付款
        this.getEnterpriseBatchList();
      }
    },
  },
};
</script>

<style scoped lang="scss">
.width512 {
  width: 400px;
}
.cardDialog {
  .addTitle {
    font-size: 20px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: bold;
    color: rgba(0, 0, 0, 0.85);
  }
  .tip {
    font-size: 14px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: rgba(0, 0, 0, 0.65);
    margin-top: 12px;
    margin-bottom: 30px;
    span {
      color: #03bfc6;
    }
  }
  .tip1 {
    font-size: 12px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #869daa;
    // line-height: 17px;
  }
  :deep(.el-form-item--small.el-form-item:nth-of-type(2)) {
    margin-bottom: 0;
  }
  :deep(.el-dialog) {
    border-radius: 16px;
  }
  :deep(.el-dialog__body) {
    padding: 10px 40px;
    padding-bottom: 60px;
  }
  :deep(.el-button--small) {
    width: 74px;
  }
  :deep(.el-input__inner) {
    padding-left: 12px;
  }
  :deep(.el-form-item__content) {
    position: relative;
  }
  .form-img {
    width: 22px;
    border-radius: 22px;
    position: absolute;
    top: 5px;
    left: 10px;
    z-index: 1;
  }
}

.title {
  color: #4f595f;
  position: relative;
  font-size: 18px;
  font-weight: 500;
  line-height: 34px;
  margin-left: 10px;
}
.textBox {
  display: flex;
  .label {
    color: #869daa;
    font-size: 14px;
    width: 120px;
    margin-left: 10px;
    text-align: right;
  }
  .val {
    font-size: 14px;
    margin-left: 20px;
    color: #869daa;
    width: 700px;
  }
}
.pedding {
  color: #f69c1f;
}
.succeed {
  color: #07a555;
}
.failed {
  color: #f42b2b;
}

.tabWrap {
  // height: 210px;
  height: 133px;
  // background: #ccc;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  .search {
    // position: absolute;
    // top: -60px;
    // right: 0;
    width: 466px;
  }
  .backWrap {
    height: 20px;
    position: absolute;
    bottom: 8px;
    right: 10px;
    display: flex;
    align-items: center;
    cursor: pointer;
    span {
      display: inline-block;
      font-size: 14px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #03bfc6;
      margin-right: 10px;
    }
  }
}
.switch {
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ml {
  margin-left: 50px;
}

.searchBtn {
  margin-top: 18px;
  background: #f5f5f5;
}

:deep(.el-tabs__item) {
  width: 130px;
}
:deep(.leftSelect) {
  .el-input__inner {
    border-radius: 4px 0 0 4px;
  }
}
:deep(.rightSelect) {
  .el-input__inner {
    border-radius: 0 4px 4px 0;
  }
}

:deep(.search) {
  .el-input__inner {
    border-radius: 2px 0 0 2px;
    height: 38px;
    line-height: 38px;
  }
}
:deep(.searBtn) {
  .el-button--small {
    border-radius: 0 2px 2px 0;
    padding: 12px 24px;
  }
}
</style>
